<?php

class ProductController extends BaseController {

	// CRUD Mode
	public $crud = true;

	// Table
	public $table = 'product';

	// Model Class Name
	public $model = 'Product';

	// Use to create filter and Manipulate Model
	public function setListData($data, $object) {
		// e.g filter using name
		if(isset($data['filter_name'])) {
			$object = $object->where('name', '=', $data['filter_name']);
		}

		return $object;
	}

	// Use to add data on List View
	public function addListData($data) {
		return $data;
	}

	// Use to add data on Form
	public function addFormData($data, $id=null) {
		return $data;
	}

	// Use to add show on Data
	public function addShowData($data, $id=null) {
		return $data;
	}

	#STORE
	// Use to manipulate data before 'store' or 'inserting'
	public function preStore($data) {
		return $data;
	}

	
	// Use to manipulate data after 'store' or 'inserting'
	public function postStore($data, $object) {
		return $data;
	}

	#UPDATE
	// Use to manipulate data before 'update'
	public function preUpdate($data) {
		return $data;
	}

	// Use to manipulate data after 'update'
	public function postUpdate($data, $object) {
		return $data;
	}

	#DESTROY
	// Use to manipulate data before 'destroy'
	public function preDestroy($id) {
		return $data;
	}

	// Use to manipulate data after 'destroy'
	public function postDestroy($id) {
		return $this->model->where('id', '=', $id)->first();
	}
}